﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace KryptonPalettesComposer.Common
{
    public static class Utils
    {
        [DllImport("dwmapi.dll")]
        private static extern void DwmIsCompositionEnabled(ref bool pfEnabled);

        public static bool IsCompositionEnabled
        {
            get
            {
                if (Environment.OSVersion.Version.Major < 6)
                    return false;

                bool compositionEnabled = false;
                DwmIsCompositionEnabled(ref compositionEnabled);
                return compositionEnabled;
            }
        }

        public static String Frmt(this string value, params object[] args)
        {
            return String.Format(value, args);
        }

        public static string UppercaseFirst(this string value)
        {
            if (value.Length <= 1)
                return value.ToUpper();

            Char[] letters = value.ToCharArray();
            letters[0] = Char.ToUpper(letters[0]);
            return new string(letters);
        }
    }
}
